import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useWeatherStore = defineStore('weather', () => {
  type DataObject = {
    cloud: string
    fxDate: string
    humidity: string
    iconDay: string
    iconNight: string
    moonPhase: string
    moonPhaseIcon: string
    moonrise: string
    moonset: string
    precip: string
    pressure: string
    sunrise: string
    sunset: string
    tempMax: string
    tempMin: string
    textDay: string
    textNight: string
    uvIndex: string
    vis: string
    wind360Day: string
    wind360Night: string
    windDirDay: string
    windDirNight: string
    windScaleDay: string
    windScaleNight: string
    windSpeedDay: string
    windSpeedNight: string
  }

  type Data24Object = {
    fxTime: string
    temp: string
    icon: string
    text: string
    wind360: string
    windDir: string
    windScale: string
    windSpeed: string
    humidity: string
    pop: string
    precip: string
    pressure: string
    cloud: string
    dew: string
  }

  type DataQualityObject = {
    date: string
    type: string
    name: string
    level: string
    category: string
    text: string
  }

  const weatherdata = ref<DataObject[]>([])

  const weather24data = ref<Data24Object[]>([])

  const qualitydata = ref<DataQualityObject[]>([])

  const modifydata = (data: DataObject[]) => {
    weatherdata.value = data
  }
  const modify24data = (data: Data24Object[]) => {
    weather24data.value = data
  }

  const modifyqualitydata = (data: DataQualityObject[]) => {
    qualitydata.value = data
  }
  return {
    weatherdata,
    modifydata,
    weather24data,
    modify24data,
    modifyqualitydata,
    qualitydata
  }
})
